// 兼容 IE
// https://github.com/zloirock/core-js/blob/master/docs/2019-03-19-core-js-3-babel-and-a-look-into-the-future.md#babelpolyfill
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'

import 'normalize.css/normalize.css' // A modern alternative to CSS resets

import ElementUI from 'element-ui'
import '@/styles/element-variables.scss'
import '@/styles/index.scss' // global css
import '@/assets/theme/index.css'

import App from '@/App'
import store from '@/store'
import router from '@/router'

import '@/icons' // icon
import '@/permission' // permission control

import * as filters from '@/filters' // global filters

// 根据浏览器宽度自动设置界面组件大小
let winWidth = 0
if (window.innerWidth) {
  winWidth = window.innerWidth
} else if ((document.body) && (document.body.clientWidth)) {
  winWidth = document.body.clientWidth
}
let size = 'medium'
if (winWidth >= 1920) {
  size = 'medium'
} else if (winWidth >= 1200) {
  size = 'small'
} else if (winWidth >= 992) {
  size = 'small'
} else if (winWidth >= 768) {
  size = 'small'
} else {
  size = 'mini'
}

Vue.use(ElementUI, {
  size: size
})

// 主题
document.body.className = 'default-theme'

Object.keys(filters).forEach(key => {
  Vue.filter(key, filters[key])
})

Vue.config.productionTip = false

const vue = new Vue({
  el: '#app',
  router,
  store,
  render: h => h(App)
})

export default vue
